package com.halixun.d2app.net;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * @ProjectName: MyOrderSystem
 * @Package: com.hlddl.order.net
 * @ClassName: AppendUrlParamIntercepter
 * @Description: java类作用描述
 * @Author: hdx
 * @CreateDate: 2019/11/28 10:23
 * @UpdateUser: hdx
 * @UpdateDate: 2019/11/28 10:23
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class AppendUrlParamIntercepter implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
//        //偷天换日
//        Request oldRequest = chain.request();
//
//        //拿到拥有以前的request里的url的那些信息的builder
//        HttpUrl.Builder builder = oldRequest
//                .url()
//                .newBuilder();
//
//        //得到新的url（已经追加好了参数）
//        HttpUrl newUrl = builder.addQueryParameter("deviceId", "12345")
//                .addQueryParameter("token", "i_am_token")
//                .addQueryParameter("appVersion", "1.0.0-beta")
//                .build();
//
//        //利用新的Url，构建新的request，并发送给服务器
//        Request newRequest = oldRequest
//                .newBuilder()
//                .url(newUrl)
//                .build();
//        return chain.proceed(newRequest);
        return chain.proceed(chain.request());
    }
}
